package cn.iocoder.yudao.module.erp.dal.mysql.contacts.customer;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.contacts.customer.vo.CustomerPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.contacts.customer.CustomerDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 客户 Mapper
 *
 * @author maxuxu
 */
@Mapper
public interface CustomersMapper extends BaseMapperX<CustomerDO> {

    default PageResult<CustomerDO> selectPage(CustomerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerDO>()
                .likeIfPresent(CustomerDO::getName, reqVO.getName())
                .likeIfPresent(CustomerDO::getContacterName, reqVO.getContacterName())
                .eqIfPresent(CustomerDO::getMobile, reqVO.getMobile())
                .eqIfPresent(CustomerDO::getEmail, reqVO.getEmail())
                .eqIfPresent(CustomerDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(CustomerDO::getDescription, reqVO.getDescription())
                .eqIfPresent(CustomerDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CustomerDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CustomerDO::getContacterTitle, reqVO.getContacterTitle())
                .eqIfPresent(CustomerDO::getGroupId, reqVO.getGroupId())
                .orderByDesc(CustomerDO::getId));
    }

}